$(function() {

    //赋值手机号码
    var telephone = $(".retrieve-input .telephone");
    var telephoneval = telephone.val();

    //赋值验证码
    var verification = $(".retrieve-input .verification");
    var verificationval = verification.val();

    //焦点
    telephone.focus(function() {
        if (telephone.val() == '手机号码') {
            $(this).val("");
        } else if (telephone.val() == '') {
            $(this).val("手机号码");
        }
        $(this).css({
            "border-color": "#e8b768",
            "transition": "0.4s"
        });
    })
    telephone.blur(function() {
        if (telephone.val() == "") {
            $(this).val("手机号码");
        }
        $(this).css({
            "border-color": "#323232",
            "transition": "0.4s"
        });
    })
    verification.focus(function() {
        if (verification.val() == "短信验证码") {
            $(this).val("");
        } else if (verification.val() == '') {
            $(this).val("短信验证码");
        }
        $(this).css({
            "border-color": "#e8b768",
            "transition": "0.4s"
        });
    })
    verification.blur(function() {
        if (verification.val() == "") {
            $(this).val("短信验证码");
        }
        $(this).css({
            "border-color": "#323232",
            "transition": "0.4s"
        });
    })

    //下一步判断

    $(".retrieve-main .button").click(function() {
        if (telephone.val() == '手机号码') {
            $(".telephone-prompt").html("手机号码为空！")
        } else if (!telephone.val().match(/^(13|14|15|17|18)\d{9}$/)) {
            $(".telephone-prompt").html("手机号码格式错误！")
        } else {
            $(".telephone-prompt").html("")
        }
        if (verification.val() == '短信验证码') {
            $(".verification-prompt").html("短信验证码为空！")
        } else {
            $(".verification-prompt").html("")
        }
    })

    //找回密码2

    //input焦点
    var password1 = $(".retrieve-input .password1");
    var password2 = $(".retrieve-input .password2");

    password1.focus(function() {
        if (password1.val() == '新密码') {
            password1.attr('type', 'password');
            password1.val('')
        } else if (password1.val() == '') {
            password1.val('新密码')
            password1.attr('type', 'text');
        }
        $(this).css({
            "border-color": "#e8b768",
            "transition": "0.4s"
        });
    })

    password1.blur(function() {
        if (password1.val() == '') {
            password1.attr('type', 'text');
            password1.val('新密码')
        }
        $(this).css({
            "border-color": "#323232",
            "transition": "0.4s"
        });
    })
    password2.focus(function() {
        if (password2.val() == '重复新密码') {
            password2.attr('type', 'password');
            password2.val('')
        } else if (password2.val() == '') {
            password2.val('重复新密码')
            password2.attr('type', 'text');
        }
        $(this).css({
            "border-color": "#e8b768",
            "transition": "0.4s"
        });
    })

    password2.blur(function() {
        if (password2.val() == '') {
            password2.attr('type', 'text');
            password2.val('重复新密码')
        }
        $(this).css({
            "border-color": "#323232",
            "transition": "0.4s"
        });
    })

    //验证

    $(".retrieve-view .button").click(function() {
        if (password1.val() == '新密码') {
            $('.password1-prompt').html('密码为空！请输入密码！')
        } else if (password1.val().length > 16) {
            $('.password1-prompt').html('密码过长！请重新输入！')
        } else if (password1.val().length <= 6) {
            $('.password1-prompt').html('密码过短！请重新输入！')
        } else {
            $('.password1-prompt').html('')
        }
        if (password2.val() == '重复新密码') {
            $('.password2-prompt').html('密码为空！请输入密码！')
        } else if (password1.val() == password2.val()) {
            $('.password2-prompt').html('')
        } else {
        	$('.password2-prompt').html('密码不一样！请重新输入！')
        }
    })
})
